package com.example.hcbmsm.controller;

import com.example.hcbmsm.domain.Op;
import com.example.hcbmsm.service.OpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author Xinghm
 * @version 1.0
 * @since 2024/10/30 16:11
 */
@RestController
@CrossOrigin
@RequestMapping("/op")
public class OpController {
    @Autowired
    private OpService opService;

    @GetMapping("/list")
    public Map findAllOp(String token) {
        return opService.findAllOp(token);
    }

    @PostMapping("/add")
    public Map add(String token, @RequestBody Op op) {
        return opService.add(token, op);
    }

    @PostMapping("/renew")
    public Map renew(@RequestBody Op op) {
        return opService.renew(op);
    }

    @PostMapping("/remove")
    public Map remove(Long opId) {
        return opService.remove(opId);
    }
}
